<template>
    <div class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed">
        <iframe ref="lcDesignIframe" :src="iframeSrc" :height="height" width="100%" frameborder="0"></iframe>
    </div>
</template>  
<script>

import { SET_BREADCRUMB } from "@/store/breadcrumbs.module";
import Swal from "sweetalert2";
import apiUtil from "@/core/util/apiUtil.js";
import { handleNotify, handleAlert, handleConfirm, showWating, closeWating, dateformat } from "@/core/util/jehcUtil.js";
export default {
    data() {
        return {
            iframeSrc:process.env.BASE_URL+"deng/view/workflow/lc-design2.0/index.html",
            height:KTUtil.getViewPort().height-160,
            // height:KTUtil.getDocumentHeight()-220,
            // iframeSrc:"http://localhost:8089/view/workflow/lc-design/lc-design2.0.html",
            // model: null,
            // graph: null,
            // toolbar: null,
            // color: '',
            // provinceList: [],
            // cityList: [],
            // communityList: [],
            // garageList: [],
            // requestInfo: {},
            // garageEdit: {},
            // uploadUrl: process.env.VUE_APP_BASE_API + 'api-web/ossUpload/uploadFile',
            // excelFlag: false,
            // uploadVisible: false,
            // sidebar: null,
            // palettes: {},
        }
    },
    components: {
    },
    mounted() {
        this.$store.dispatch(SET_BREADCRUMB, [{ title: "在线设计" }]);
        this.initIframeWin();
    },
    methods: {
        initIframeWin() {
            let oauthModules = process.env.VUE_APP_OAUTH_API;

            //监控中心API
            let monitorModules = process.env.VUE_APP_MONITOR_API;

            //运维中心API
            let opModules = process.env.VUE_APP_OP_API;

            //平台中心API
            let sysModules = process.env.VUE_APP_SYS_API;

            //工作流中心API
            let workflowModules = process.env.VUE_APP_WORKFLOW_API;

            //文件中心API
            let fileModules = process.env.VUE_APP_FILE_API;

            //日志中心API
            let logModules = process.env.VUE_APP_LOG_API;

            //即时通讯中心API
            let imModules = process.env.VUE_APP_IM_API;

            //即时通讯中心WebSocket
            let imWebSocketModules = process.env.VUE_APP_IM_WEBSOCKET_API;

            //报表中心API
            let reportModules = process.env.VUE_APP_REPORT_API;

            //调度中心API
            let jobModules = process.env.VUE_APP_JOB_API;

            //病历云API
            let medicalModules = process.env.VUE_APP_MEDICAL_API;

            //运管平台API
            let ompModules =process.env. VUE_APP_OMP_API;

            const lcDesignIframe = this.$refs.lcDesignIframe
            let params = { 
                oauthModules: oauthModules, 
                monitorModules: monitorModules,
                opModules:opModules,
                sysModules:sysModules,
                workflowModules:workflowModules,
                fileModules:fileModules,
                logModules:logModules,
                imModules:imModules,
                imWebSocketModules:imWebSocketModules,
                reportModules:reportModules,
                jobModules:jobModules,
                medicalModules:medicalModules,
                ompModules:ompModules,
                basePath: process.env.BASE_URL 
            }
            // 因为iframe页面打开就已经加载 获取接口成功后刷新他                   
            lcDesignIframe.contentWindow.location.reload()
            if (lcDesignIframe.attachEvent) {
                // 兼容浏览器判断 // iframe的加载完成函数         
                lcDesignIframe.attachEvent('onload', function () {
                    const iframeWin = lcDesignIframe.contentWindow
                    //传递参数           
                    iframeWin.postMessage(params, '*')
                })
            } else {
                // iframe的加载完成函数         
                lcDesignIframe.onload = function () {
                    const iframeWin = lcDesignIframe.contentWindow
                    console.log(iframeWin);
                    //传递参数           
                    iframeWin.postMessage(params, '*')
                }
            }
        },
    }
};
</script>
